package com.maoxx.libms.vo;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @className: Result
 * @author: Maoxx
 * @date: 2024/10/25 19:58
 * @Version: 1.0
 * @description:
 */

@Data
public class Result <T> {
    private Integer code;
    private String msg;
    private T data;
    private Map map = new HashMap(); // 动态数据


    public static  <T> Result<T> success(T data) {
        Result<T> r = new Result<T>();
        r.data = data;
        r.code = 1;
        return r;
    }

    public static <T> Result<T> error(String message) {
        Result<T> r = new Result<T>();
        r.msg = message;
        r.code = 0;
        return r;
    }

    public Result<T> add(String key, Object value) {
        this.map.put(key, value);
        return this;
    }

}
